package com.xca.znb.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class TrendsDBHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "trends.db" ;
    private static final int DATABASE_VERSION = 1 ;

    public static final String TABLE_TRENDS = "trends" ;
    public static final String TRENDS_ID = "id" ;
    public static final String TRENDS_TEXT = "text" ;
    public static final String TRENDS_IMG_LIST = "img_list" ;
    public static final String TRENDS_PUBLISHER = "publisher" ;

    private static final String CREATE_TABLE_TRENDS = "CREATE TABLE " + TABLE_TRENDS + " ( " +
            TRENDS_ID + " INTEGER PRIMARY KEY AUTOINCREMENT , " +
            TRENDS_TEXT + " TEXT , " +
            TRENDS_IMG_LIST + " TEXT , " +
            TRENDS_PUBLISHER + " TEXT ) " ;

    public TrendsDBHelper(@Nullable Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TABLE_TRENDS);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_TRENDS);
        onCreate(db);
    }
}
